package cn.exempale.mscapplication.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import cn.exempale.mscapplication.R;
import cn.exempale.mscapplication.databinding.ItemFileBinding;
import cn.exempale.mscapplication.vo.FileVO;

public class FileAdapter extends RecyclerView.Adapter<FileAdapter.FileViewHolder> {

    private Context context;
    private List<FileVO> fileVOS;

    public FileAdapter(Context context) {
        this.context = context;
        this.fileVOS = new ArrayList<>();
    }

    public void setFileVOS(List<FileVO> fileVOS) {
        this.fileVOS = fileVOS;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public FileViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        LayoutInflater inflater = LayoutInflater.from(context);
        ItemFileBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_file, parent, false);
        return new FileViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull FileViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return fileVOS == null ? 0 : fileVOS.size();
    }

    class FileViewHolder extends RecyclerView.ViewHolder {

        private ItemFileBinding binding;

        public FileViewHolder(@NonNull ItemFileBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }
}
